package  
{
	import flash.display.Sprite;
	/**
	 * ...
	 * @author Lorenzo Nuvoletta
	 */
	public class GenerateGraphicGrid extends Sprite
	{
		public var nodesList:Vector.<Node> = new Vector.<Node>();		
		
		public function GenerateGraphicGrid(w:int, h:int)
		{
			// Create the graphic grid.
			// Dont need to create this if you already have it.
			for (var i:int = 0; i < w * h; ++i ) {
				var tile:Tile = new Tile();				
				tile.x = i % w * tile.width +50;
				tile.y = int(i / w) * tile.height +50;
				addChild(tile);				
				
				//Creating Nodes
				var node:Node = new Node(i % w, int(i / w));				
				node.posX = tile.x;
				node.posY = tile.y;				
				if (Math.random() < .7) {
				//if(i%7 != 0 && i%17!=0){
					tile.gotoAndStop(1);
					node.closed = false;								
				}
				else {
					tile.gotoAndStop(2);
					node.closed = true;										
				}				
				nodesList.push(node);
			}
		}
		
	}

}